package servlet.car;

import domain.Car;
import service.CarsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;
import java.io.IOException;

//购买商品
@WebServlet("/BuyCarGoodsSerclet")
public class BuyCarGoodsSerclet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        int id = Integer.parseInt(request.getParameter("id"));
       CarsService carsService = new CarsService();
       Car c = carsService.findCarMsgById(id);
       carsService.findCarMsgById(id);
       String zp =  c.getGoodspic();
        session.setAttribute("zp", zp);
       request.setAttribute("car", c);
       request.getRequestDispatcher("buy_car.jsp").forward(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
